package com.test;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/****
 * 得到一个全局的值
 * 需要先执行   http://localhost:8080/servlet-demo/servletContextDemo2
 * 再执行http://localhost:8080/servlet-demo/servletContextDemo3
 */
@WebServlet(value="/servletContextDemo3")
public class ServletContextDemo3  extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String name= (String) req.getServletContext().getAttribute("user");
		System.out.println("name:"+name);
	}
}
